package com.clx.weblog.common.domain.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.clx.weblog.common.domain.dos.CategoryDo;

public interface CategoryMapper extends BaseMapper<CategoryDo> {

    // 根据用户名查询
    default CategoryDo selectByName(String categoryName) {
        // 构建查询条件
        // 对应sql SELECT * FROM category WHERE name = #{categoryName}
        LambdaQueryWrapper<CategoryDo> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(CategoryDo::getName, categoryName);

        // 执行查询
        return selectOne(wrapper);
    }
}
